function backPropData = feedForward(pattern, weightsVector, solution)
    global LAYERS;
%TRAINSIMPLEPERCEPTRON
%   This function trains a simple perceptron with a given pattern, a 
%   weights vector, the expected 
%   solution for each pattern (b). An exitation function (g)
%   and its derived function (gp) and compute de deltas for the output
%   layer
%   
%   Input
%
%   pattern: The pattern to train
%   weightsVector: The array of matrixes of weights for each layer.
%
%   Output:
%   wf: The array of matrixes of the trained weigths.
%

	nOfLayers = length(LAYERS);
    backPropData = cell(1,2);
    backPropData{1} = cell(1, nOfLayers);

	% PROPAGATE SIGNAL
    layerNeurons = pattern;
    for j = 1:nOfLayers                                         % for each layer, obtain output of the units in that layer and propagate! We add the -1 as the threshold
        hj = weightsVector{j}*vertcat(-1, layerNeurons);        % select matrix_j which represents weights between units in layer j and its predecesor units + thresholds
        backPropData{1}{j} = hj;
        layerNeurons = g_function(hj);
    end
    backPropData{2} = gp_function(hj).*(solution - layerNeurons);
end


